package com.lantian.uavmaterial.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lantian.common.annotation.Log;
import com.lantian.common.core.controller.BaseController;
import com.lantian.common.core.domain.AjaxResult;
import com.lantian.common.enums.BusinessType;
import com.lantian.uavmaterial.domain.UavCommunicationDatalink;
import com.lantian.uavmaterial.service.IUavCommunicationDatalinkService;
import com.lantian.common.utils.poi.ExcelUtil;
import com.lantian.common.core.page.TableDataInfo;

/**
 * 无人机通信与数传Controller
 * 
 * @author lantian
 * @date 2025-11-06
 */
@RestController
@RequestMapping("/uav/communication")
public class UavCommunicationDatalinkController extends BaseController
{
    @Autowired
    private IUavCommunicationDatalinkService uavCommunicationDatalinkService;

    /**
     * 查询无人机通信与数传列表
     */
    @PreAuthorize("@ss.hasPermi('uav:communication:list')")
    @GetMapping("/list")
    public TableDataInfo list(UavCommunicationDatalink uavCommunicationDatalink)
    {
        startPage();
        List<UavCommunicationDatalink> list = uavCommunicationDatalinkService.selectUavCommunicationDatalinkList(uavCommunicationDatalink);
        return getDataTable(list);
    }

    /**
     * 导出无人机通信与数传列表
     */
    @PreAuthorize("@ss.hasPermi('uav:communication:export')")
    @Log(title = "无人机通信与数传", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UavCommunicationDatalink uavCommunicationDatalink)
    {
        List<UavCommunicationDatalink> list = uavCommunicationDatalinkService.selectUavCommunicationDatalinkList(uavCommunicationDatalink);
        ExcelUtil<UavCommunicationDatalink> util = new ExcelUtil<UavCommunicationDatalink>(UavCommunicationDatalink.class);
        util.exportExcel(response, list, "无人机通信与数传数据");
    }

    /**
     * 获取无人机通信与数传详细信息
     */
    @PreAuthorize("@ss.hasPermi('uav:communication:query')")
    @GetMapping(value = "/{uavCommunicationId}")
    public AjaxResult getInfo(@PathVariable("uavCommunicationId") String uavCommunicationId)
    {
        return success(uavCommunicationDatalinkService.selectUavCommunicationDatalinkByUavCommunicationId(uavCommunicationId));
    }

    /**
     * 新增无人机通信与数传
     */
    @PreAuthorize("@ss.hasPermi('uav:communication:add')")
    @Log(title = "无人机通信与数传", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UavCommunicationDatalink uavCommunicationDatalink)
    {
        return toAjax(uavCommunicationDatalinkService.insertUavCommunicationDatalink(uavCommunicationDatalink));
    }

    /**
     * 修改无人机通信与数传
     */
    @PreAuthorize("@ss.hasPermi('uav:communication:edit')")
    @Log(title = "无人机通信与数传", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UavCommunicationDatalink uavCommunicationDatalink)
    {
        return toAjax(uavCommunicationDatalinkService.updateUavCommunicationDatalink(uavCommunicationDatalink));
    }

    /**
     * 删除无人机通信与数传
     */
    @PreAuthorize("@ss.hasPermi('uav:communication:remove')")
    @Log(title = "无人机通信与数传", businessType = BusinessType.DELETE)
	@DeleteMapping("/{uavCommunicationIds}")
    public AjaxResult remove(@PathVariable String[] uavCommunicationIds)
    {
        return toAjax(uavCommunicationDatalinkService.deleteUavCommunicationDatalinkByUavCommunicationIds(uavCommunicationIds));
    }
}
